package com.wandian.cqcsk.mvvm.mine.helpandsuggest;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import androidx.databinding.DataBindingUtil;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.mvvm.BaseMVVMActivity;
import com.mylib.libcore.utils.ActivityUtil;
import com.mylib.libcore.utils.ToastUtil;
import com.wandian.cqcsk.R;
import com.wandian.cqcsk.adapter.mine.HelpAndSuggesGridViewAdapter;
import com.wandian.cqcsk.databinding.ActivityHelpAndSuggestBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 * @date 2019/12/18-14:28
 * @description 帮助与反馈
 **/
@Route(path = RouterConfig.ROUTER_ACTIVITY_HELPANDSUGGEST)
public class HelpAndSuggestActivity extends BaseMVVMActivity<HelpAndSuggestViewModel> {
    private ActivityHelpAndSuggestBinding dataBinding;
    private HelpAndSuggesGridViewAdapter helpAndSuggesGridViewAdapter;
    @Override
    public void init(Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_help_and_suggest);
        dataBinding.setLifecycleOwner(this);
        dataBinding.setViewModel(mViewModel);
        initViewData();
        initClink();
    }
    private void initViewData(){
        ActivityUtil.getInstance().showStatusView(this,dataBinding.viewSysTop,true);
        dataBinding.bindTransparentToolBar.toolBarTvTitle.setText("帮助反馈");
        dataBinding.bindTransparentToolBar.toolBarTitleRight.setText("我的反馈");

        dataBinding.bindTransparentToolBar.toolBarTitleRight.setVisibility(View.VISIBLE);
        List<String> titles = new ArrayList<>();
        titles.add("升级奖励");
        titles.add("注意事项");


        List<Integer> picIds = new ArrayList<>();
        picIds.add(R.drawable.img_help_sjfl);
        picIds.add(R.drawable.img_help_qdgz);
        picIds.add(R.drawable.img_help_zhsz);


        helpAndSuggesGridViewAdapter = new HelpAndSuggesGridViewAdapter(getContext(),titles,picIds);
        dataBinding.mygrid.setAdapter(helpAndSuggesGridViewAdapter);
        dataBinding.mygrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String key = "";
                switch (position){
                    case 0:
                        key = "升级奖励";
                        break;
                    case 1:
                        key = "注意事项";
                        break;

                }
                ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_HELP_OTHER_PAGE).withString("title",key).navigation();
            }
        });

    }
    private void initClink(){
        dataBinding.bindTransparentToolBar.toolBarIvBack.setOnClickListener(v ->finish());

        //我的反馈
        dataBinding.bindTransparentToolBar.toolBarTitleRight.setOnClickListener(v -> ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_MINE_HISTORY).navigation());
        //建议
        dataBinding.tvButton.setOnClickListener(v -> ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_HELP_SUGGEST).navigation());
    }


}
